<script setup lang="ts">
import { ref } from 'vue'
import Navbar from './navbar.vue'
import UserDrawer from './components/UserDrawer.vue'
import { getAssetsImge } from '/@/utils/getImge'
import ChatInput from './components/ChatInput.vue'
import ExamList from './components/ExamList.vue'
import FriendsSidebar from './components/FriendsSidebar.vue'

interface ChatMessage {
  id: number
  sender: string
  content: string
  time: string
  isMe?: boolean
  avatar?: string
}

interface ChatUser {
  name: string
  avatar: string
  lastSeen: string
  online?: boolean
}

const currentUser: ChatUser = {
  name: 'Michelle Green',
  avatar: 'avatar.svg',
  lastSeen: 'days ago'
}

const messages = ref<ChatMessage[]>([
  {
    id: 1,
    sender: 'Michelle',
    content: 'Hello, How are you?',
    time: '7:19 PM',
    avatar: '👩'
  },
  {
    id: 2,
    sender: 'Michelle',
    content: 'Okay, All the Lorem Ipsum generators on the Internet',
    time: '7:19 PM',
    avatar: '👩'
  },
  {
    id: 3,
    sender: 'Me',
    content: 'Hi Michelle! I\'m doing great, thanks for asking. How about you?',
    time: '7:20 PM',
    isMe: true,
    avatar: '👨'
  }
])

const messageInput = ref('')
const recentChats = ref([
  {
    id: 1,
    name: 'Support ChatBot',
    avatar: '🤖',
    online: true,
    lastMessage: 'Online',
    time: '11:08 am',
    unread: 2,
    isGroup: false
  },
  {
    id: 2,
    name: 'Jason Porter',
    avatar: '👨',
    lastMessage: 'It is a long established fact that a reade...',
    time: '11:08 am',
    online: true,
    unread: 0,
    isGroup: false
  },
  {
    id: 3,
    name: 'UI-Design Group',
    avatar: '👥',
    lastMessage: 'It is a long established fact that a rea...',
    time: '11:08 am',
    members: ['👨', '👩', '👨', '👨'],
    unread: 5,
    isGroup: true
  },
  {
    id: 4,
    name: 'Michelle Green',
    avatar: '👩',
    lastMessage: 'What Can i do right now?',
    time: '11:08 am',
    online: false,
    unread: 0,
    isGroup: false
  }
])

const showEmojiPicker = ref(false)
const showAttachMenu = ref(false)

const attachOptions = [
  { icon: 'fas fa-image', label: 'Image' },
  { icon: 'fas fa-file', label: 'Document' },
  { icon: 'fas fa-video', label: 'Video' },
  { icon: 'fas fa-map-marker-alt', label: 'Location' }
]

const emojis = [
  '😀', '😃', '😄', '😁', '😅', '😂', '🤣', '😊', '😇', '🙂', '🙃', '😉', '😌', 
  '😍', '🥰', '😘', '😗', '😙', '😚', '😋', '😛', '😝', '😜', '🤪', '🤨', '🧐'
]

const toggleEmojiPicker = () => {
  showEmojiPicker.value = !showEmojiPicker.value
}

const insertEmoji = (emoji: string) => {
  messageInput.value += emoji
}

const handleAttach = (type: string) => {
  console.log('Attaching:', type)
  showAttachMenu.value = false
}

const sendMessage = () => {
  if (!messageInput.value.trim()) return

  messages.value.push({
    id: messages.value.length + 1,
    sender: 'Me',
    content: messageInput.value,
    time: new Date().toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' }),
    isMe: true
  })

  messageInput.value = ''
  showEmojiPicker.value = false
}

const showUserDrawer = ref(false)
const selectedChat = ref<ChatUser>(currentUser)

const handleUserClick = (chat:ChatUser) => {
  selectedChat.value = chat
  showUserDrawer.value = true
}

const handleSendMessage = (message: string) => {
  messages.value.push({
    id: messages.value.length + 1,
    sender: 'Me',
    content: message,
    time: new Date().toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' }),
    isMe: true,
    avatar: '👨'
  })
}
</script>

<template>
  <div class="chat-page">
    <!--    <Navbar />-->
    <div class="chat-container">
      <!-- 左侧边栏 -->
      <div class="sidebar">
        <div class="header">
          <h1>Chat</h1>
          <button class="new-chat-btn">
            <i class="fa fa-plus"></i>
            New Chat
          </button>
        </div>

        <div class="search-box">
          <i class="fa fa-search search-icon"></i>
          <input type="text" placeholder="Search in messages..." />
        </div>

        <div class="recent-chats">
          <div class="section-header">
            <h2>RECENT CHATS</h2>
            <button class="more-btn">
              <i class="fa fa-ellipsis-h"></i>
            </button>
          </div>

          <div v-for="chat in recentChats"
               :key="chat.id"
               class="chat-item"
               :class="{ 'active': chat.name === currentUser.name }">
            <div class="chat-avatar">
              <div class="avatar-wrapper">
                <img 
                  v-if="chat.isGroup" 
                  :src="getAssetsImge('avatar.svg')" 
                  class="avatar-image"
                />
                <span v-else class="avatar-text">{{ chat.avatar }}</span>
              </div>
              <span v-if="chat.online" class="online-indicator"></span>
            </div>

            <div class="chat-info">
              <div class="chat-header">
                <span class="chat-name">{{ chat.name }}</span>
                <span class="chat-time text-muted">{{ chat.time }}</span>
              </div>

              <div class="chat-footer">
                <span class="last-message">
                  <i v-if="chat.isGroup" class="fa fa-users group-icon"></i>
                  {{ chat.lastMessage }}
                </span>
                <div class="chat-indicators">
                  <span v-if="chat.unread" class="badge">{{ chat.unread }}</span>
                </div>
              </div>

              <div v-if="chat.isGroup" class="group-members">
                <div class="member-avatars">
                  <span v-for="(member, index) in chat.members"
                        :key="index"
                        class="member-avatar"
                        :style="{ zIndex: chat.members.length - index }">
                    {{ member }}
                  </span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 主聊天区域 -->
      <div class="main-chat">
        <div class="chat-header">
          <div class="header-content">
            <div class="user-info" @click="handleUserClick(currentUser)">
              <div class="avatar-wrapper">
                <img 
                  :src="getAssetsImge(currentUser.avatar)" 
                  :alt="currentUser.name"
                  class="avatar-image"
                />
                <span class="online-status"></span>
              </div>
              <div class="user-details">
                <h2>{{ currentUser.name }}</h2>
                <span class="user-status">Last seen {{ currentUser.lastSeen }}</span>
              </div>
            </div>
            
            <div class="header-actions">
              <button class="action-btn" title="Search in conversation">
                <i class="fa fa-search"></i>
              </button>
              <button class="action-btn" title="Start video call">
                <i class="fa fa-video-camera"></i>
<!--                <span class="action-badge">New</span>-->
              </button>
              <button class="action-btn" title="Start voice call">
                <i class="fa fa-phone"></i>
              </button>
              <div class="action-divider"></div>
              <button class="action-btn" title="Add members">
                <i class="fa fa-user-plus"></i>
              </button>
              <button class="action-btn" title="More options">
                <i class="fa fa-ellipsis-v"></i>
              </button>
            </div>
          </div>
        </div>

        <div class="messages-container">
          <div class="messages-date">Today</div>

          <div v-for="message in messages"
               :key="message.id"
               :class="['message-wrapper', { 'message-mine': message.isMe }]">
            <div class="message-avatar" v-if="!message.isMe">
              <img :src="message.avatar" :alt="message.sender" class="avatar-img" />
            </div>
            <div class="message-content-wrapper">
              <div class="message-sender" v-if="!message.isMe">
                {{ message.sender }}
                <span class="message-time">{{ message.time }}</span>
              </div>
              <div class="message-bubble">
                {{ message.content }}
              </div>
              <div class="message-info" v-if="message.isMe">
                <span class="message-time">{{ message.time }}</span>
                <i class="fas fa-check-double message-status"></i>
              </div>
            </div>
          </div>
        </div>

        <div class="chat-input-container">
          <div class="input-wrapper">
            <!-- 更多选项按钮 -->
            <button class="input-action-btn">
              <i class="fa fa-ellipsis-h"></i>
            </button>

            <!-- 表情选择器 -->
            <div class="emoji-picker-container">
              <button class="input-action-btn" @click="toggleEmojiPicker">
                <i class="fa fa-smile-o"></i>
              </button>
              
              <!-- 表情选择面板 -->
              <div v-if="showEmojiPicker" class="emoji-picker">
                <div class="emoji-picker-header">
                  <div class="emoji-categories">
                    <button class="category-btn active">
                      <i class="fa fa-smile-o"></i>
                    </button>
                    <button class="category-btn">
                      <i class="fa fa-flag"></i>
                    </button>
                    <button class="category-btn">
                      <i class="fa fa-futbol-o"></i>
                    </button>
                    <button class="category-btn">
                      <i class="fa fa-lightbulb-o"></i>
                    </button>
                    <button class="category-btn">
                      <i class="fa fa-bell-o"></i>
                    </button>
                  </div>
                  <div class="emoji-search">
                    <input type="text" placeholder="Search emoji" />
                  </div>
                </div>
                <div class="emoji-grid">
                  <button 
                    v-for="emoji in emojis" 
                    :key="emoji"
                    class="emoji-btn"
                    @click="insertEmoji(emoji)"
                  >
                    {{ emoji }}
                  </button>
                </div>
              </div>
            </div>

            <!-- 消息输入框 -->
            <div class="message-input">
              <input 
                type="text" 
                v-model="messageInput"
                placeholder="Type a message..."
                @keyup.enter="sendMessage"
              />
            </div>

            <!-- 语音输入按钮 -->
            <button class="input-action-btn">
              <i class="fa fa-microphone"></i>
            </button>

            <!-- 发送按钮 -->
            <button 
              class="send-btn"
              :class="{ 'send-btn-active': messageInput.trim() }"
              @click="sendMessage"
            >
              <i class="fa fa-paper-plane"></i>
            </button>
          </div>
        </div>
      </div>

      <FriendsSidebar />
    </div>

    <UserDrawer
      :is-open="showUserDrawer"
      :current-chat="selectedChat"
      @close="showUserDrawer = false"
    />

  </div>
</template>

<style scoped>
.chat-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-container {
  display: flex;
  flex: 1;
  background-color: #fff;
}

.sidebar {
  width: 320px;
  border-right: 1px solid #e0e0e0;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.new-chat-btn {
  background-color: #007bff;
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  transition: background-color 0.2s;
}

.new-chat-btn:hover {
  background-color: #0056b3;
}

.search-box {
  padding: 15px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 25px;
  top: 50%;
  transform: translateY(-50%);
  color: #666;
}

.search-box input {
  width: 100%;
  padding: 10px 15px 10px 35px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  background-color: #f8f9fa;
}

.section-header {
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-header h2 {
  font-size: 12px;
  color: #666;
  font-weight: 600;
  margin: 0;
}

.more-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 5px;
}

.chat-item {
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 8px;
  margin: 0 8px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-item:hover {
  background-color: #f5f5f5;
  border-color: #e0e0e0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.chat-item.active {
  background-color: #e3f2fd;
  border-color: #90caf9;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.1);
}

.chat-avatar {
  position: relative;
  flex-shrink: 0;
}

.avatar-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background-color: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-text {
  font-size: 24px;
}

.online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background-color: #4caf50;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.chat-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-name {
  font-weight: 500;
  color: #333;
  font-size: 15px;
}

.text-muted {
  color: #999;
  font-size: 12px;
}

.chat-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.last-message {
  color: #666;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.group-icon {
  margin-right: 4px;
  color: #666;
  font-size: 12px;
}

.badge {
  background-color: #007bff;
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.group-members {
  margin-top: 4px;
}

.member-avatars {
  display: flex;
  align-items: center;
}

.member-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 2px solid #fff;
  margin-right: -8px;
}

.member-avatar:last-child {
  margin-right: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.user-info:hover {
  background-color: #f5f5f5;
}

.avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
}

.avatar-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.online-status {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background-color: #4caf50;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.user-details h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.user-status {
  font-size: 13px;
  color: #666;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.action-btn:hover {
  background-color: #f5f5f5;
  color: #333;
}

.action-btn i {
  font-size: 18px;
}

.action-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background-color: #ff5757;
  color: white;
  font-size: 10px;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 500;
}

.action-divider {
  width: 1px;
  height: 24px;
  background-color: #e0e0e0;
  margin: 0 8px;
}

.action-btn::after {
  content: attr(title);
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0,0,0,0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  z-index: 1000;
}

.action-btn:hover::after {
  opacity: 1;
  visibility: visible;
}

.action-btn:active {
  transform: scale(0.95);
}

.action-btn .fa-video {
  color: #2196f3;
}

.action-btn .fa-phone {
  color: #4caf50;
}

.action-btn .fa-user-plus {
  color: #ff9800;
}

.messages-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background-color: #fff;
  min-height: 0;
}

.messages-date {
  text-align: center;
  color: #666;
  font-size: 12px;
  margin: 16px 0;
  position: relative;
}

.messages-date::before,
.messages-date::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 50px);
  height: 1px;
  background-color: #e0e0e0;
}

.messages-date::before {
  left: 0;
}

.messages-date::after {
  right: 0;
}

.message-wrapper {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  max-width: 70%;
}

.message-mine {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-sender {
  font-size: 13px;
  color: #666;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-bubble {
  background-color: #f5f5f5;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  max-width: fit-content;
}

.message-mine .message-bubble {
  background-color: #0084ff;
  color: white;
}

.message-info {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

.message-time {
  font-size: 12px;
  color: #666;
}

.message-status {
  font-size: 12px;
  color: #0084ff;
}

.message-mine .message-status {
  color: #fff;
}

.message-input-wrapper {
  padding: 16px 24px;
  background-color: #fff;
  border-top: 1px solid #e0e0e0;
}

.message-input-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: #f5f5f5;
  border-radius: 24px;
  padding: 8px 16px;
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  padding: 8px 0;
  font-size: 14px;
  color: #333;
}

.input-wrapper input::placeholder {
  color: #999;
}

.input-actions {
  display: flex;
  gap: 12px;
}

.input-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.input-action-btn:hover {
  background-color: #e0e0e0;
}

.send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background-color: #0084ff;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-btn:hover {
  background-color: #0073e6;
}

.attach-menu-wrapper {
  position: relative;
}

.attach-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 8px;
  min-width: 180px;
  z-index: 1000;
}

.attach-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.attach-option:hover {
  background-color: #f0f0f0;
}

.attach-option i {
  width: 20px;
  color: #666;
}

.attach-option span {
  font-size: 14px;
  color: #333;
}

.emoji-picker-wrapper {
  position: relative;
}

.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  width: 320px;
  z-index: 1000;
}

.emoji-picker-header {
  padding: 12px;
  border-bottom: 1px solid #e0e0e0;
}

.emoji-categories {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.category-btn {
  padding: 8px;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.category-btn:hover {
  background-color: #f0f0f0;
}

.category-btn.active {
  background-color: #e3f2fd;
  color: #007bff;
}

.emoji-search {
  margin-top: 8px;
}

.emoji-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
}

.emoji-search input:focus {
  border-color: #007bff;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.emoji-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 20px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.emoji-btn:hover {
  background-color: #f0f0f0;
}

/* 添加滚动条样式 */
.emoji-grid::-webkit-scrollbar {
  width: 6px;
}

.emoji-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.record-btn {
  position: relative;
}

.tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0,0,0,0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.record-btn:hover .tooltip {
  opacity: 1;
  visibility: visible;
}

.input-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.input-action-btn:hover {
  background-color: #f0f0f0;
  color: #333;
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background-color: #e0e0e0;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-btn-active {
  background-color: #007bff;
  color: white;
}

.send-btn-active:hover {
  background-color: #0056b3;
}

.user-info {
  cursor: pointer;
}

.user-info:hover {
  background-color: #f5f5f5;
  border-radius: 8px;
}

/* 添加右侧好友列表样式 */
.friends-sidebar {
  width: 280px;
  border-left: 1px solid #e0e0e0;
  background-color: #fff;
  display: flex;
  flex-direction: column;
}

.friends-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.header-title i {
  color: #666;
}

.friends-count {
  background-color: #f0f0f0;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  color: #666;
}

.add-friend-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background-color: #f5f5f5;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.add-friend-btn:hover {
  background-color: #e0e0e0;
}

.friends-search {
  padding: 12px 20px;
  border-bottom: 1px solid #e0e0e0;
}

.friends-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.friends-search input:focus {
  border-color: #0084ff;
}

.friends-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.friends-category {
  margin-bottom: 20px;
}

.category-header {
  padding: 0 20px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #666;
  text-transform: uppercase;
}

.category-count {
  background-color: #f0f0f0;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
}

.friend-item {
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.friend-item:hover {
  background-color: #f5f5f5;
}

.friend-avatar {
  position: relative;
  width: 40px;
  height: 40px;
}

.friend-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.status-indicator.online {
  background-color: #4caf50;
}

.status-indicator.offline {
  background-color: #9e9e9e;
}

.friend-info {
  flex: 1;
  min-width: 0;
}

.friend-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 2px;
}

.friend-status {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.friend-item:hover .friend-actions {
  opacity: 1;
}

.friend-actions .action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.friend-actions .action-btn:hover {
  background-color: #e0e0e0;
}

.friend-actions .action-btn i.fa-video {
  color: #2196f3;
}

.friend-actions .action-btn i.fa-phone {
  color: #4caf50;
}

/* 修改主容器样式以适应新的侧边栏 */
.chat-container {
  display: flex;
  height: 100vh;
  background-color: #fff;
  margin-top: 70px;
}

.main-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e0e0e0;
}

.chat-input-container {
  padding: 16px;
  background-color: #fff;
  border-top: 1px solid #e0e0e0;
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #f8f9fa;
  border-radius: 24px;
  padding: 8px 16px;
}

.input-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.input-action-btn:hover {
  background-color: #e9ecef;
  color: #333;
}

.message-input {
  flex: 1;
  margin: 0 8px;
}

.message-input input {
  width: 100%;
  border: none;
  background: none;
  padding: 8px 0;
  font-size: 14px;
  color: #333;
  outline: none;
}

.message-input input::placeholder {
  color: #999;
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  color: #ccc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-btn-active {
  background-color: #0084ff;
  color: white;
}

.send-btn-active:hover {
  background-color: #0073e6;
}

/* 表情选择器样式 */
.emoji-picker-container {
  position: relative;
}

.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  width: 320px;
  z-index: 1000;
}

.emoji-picker-header {
  padding: 12px;
  border-bottom: 1px solid #e0e0e0;
}

.emoji-categories {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.category-btn {
  padding: 8px;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.category-btn:hover {
  background-color: #f0f0f0;
}

.category-btn.active {
  background-color: #e3f2fd;
  color: #007bff;
}

.emoji-search {
  margin-top: 8px;
}

.emoji-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
}

.emoji-search input:focus {
  border-color: #007bff;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.emoji-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 20px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.emoji-btn:hover {
  background-color: #f0f0f0;
}

/* 添加滚动条样式 */
.emoji-grid::-webkit-scrollbar {
  width: 6px;
}

.emoji-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.exam-section {
  padding: 20px;
  background-color: #f5f7f9;
}

.chat-header {
  padding: 16px;
  border-bottom: 1px solid #e0e0e0;
  background-color: #fff;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.user-info:hover {
  background-color: #f5f5f5;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.recent-chats {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* 添加滚动条样式 */
.recent-chats::-webkit-scrollbar {
  width: 6px;
}

.recent-chats::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.recent-chats::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.recent-chats::-webkit-scrollbar-thumb:hover {
  background: #999;
}
</style>